﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace 桌面视频录制
{
    [Serializable]
    public class DrawClosedCurveWithFill : DrawCurve
    {
        public DrawClosedCurveWithFill(Point startPoint)
            : base(startPoint) { }
        public override void Draw(Graphics g)
        {
            if (pointList.Count > 2)
            {
                Brush brush = this.DrawBrush.GetBrush();
                g.FillClosedCurve(brush, pointList.ToArray());
                brush.Dispose();
            }
        }
        public override bool JudgeIsSelected(System.Windows.Forms.MouseEventArgs e)
        {
            if (pointList.Count < 3)
                return false;
            GraphicsPath path = new GraphicsPath();
            path.AddClosedCurve(pointList.ToArray());
            Region region = new Region(path);
            if (region.IsVisible(e.Location))
            {
                path.Dispose();
                region.Dispose();
                return true;
            }
            else
            {
                path.Dispose();
                region.Dispose();
                return false;
            }
        }
        public override string ToString()
        {
            string printMsg = "[实曲(" + this.pointList[0].X + "," + this.pointList[0].Y + ")]->[ID:" + this.Id + "]";
            return printMsg;
        }
        public override string GetDrawObjectMsg()
        {
            string drawObjectMsg = "实曲->起始位置(" + this.pointList[0].X + "," + this.pointList[0].Y + "),终点位置(" + this.pointList[pointList.Count - 1].X + "," + this.pointList[pointList.Count - 1].Y + "),样本点数:" + pointList.Count + "个";
            return drawObjectMsg;
        }
    }
}
